home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / resolvconf.postinst < prev    next >
Encoding:
Text File  |  2010-07-12  |  5.1 KB  |  166 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. . /usr/share/debconf/confmodule
  6.  
  7. MYNAME=resolvconf.postinst
  8. report() { echo "${MYNAME}: $*" ; }
  9. report_err() { report "Error: $*" >&2 ; }
  10. report_info() { report "Info: $*" >&2 ; }
  11.  
  12. ### Create /etc/resolvconf/run ###
  13. #
  14. # Unfortunately we can't keep state files in /var/run/ because 
  15. # resolvconf, as it must, initializes before networking does and
  16. # /var/ can be on the network.  In the past we used /dev/shm/
  17. # but now we use /lib/init/rw/.
  18. #
  19. case "$1" in
  20.   configure|reconfigure)
  21.     # If it's a symlink, ensure that it is canonicalizable
  22.     if [ -L /etc/resolvconf/run ] ; then
  23.         RUN_CANONICALPATH="$(readlink -f /etc/resolvconf/run || :)"
  24.         if [ -z "$RUN_CANONICALPATH" ] ; then
  25.             report_err "Deleting /etc/resolvconf/run symlink whose canonical path could not be determined"
  26.             rm -f /etc/resolvconf/run
  27.         elif \
  28.             [ "$RUN_CANONICALPATH" = "/dev/shm/resolvconf" ] \
  29.             && [ -d /lib/init/rw ] \
  30.             && [ -w /lib/init/rw ] \
  31.             && [ -r /proc/mounts ] \
  32.             && grep -qs "^tmpfs[[:space:]]\+/lib/init/rw[[:space:]]\+tmpfs[[:space:]]\+\([^[:space:]]\+,\)\?rw" /proc/mounts \
  33.             && { [ -d /lib/init/rw/resolvconf ] || mkdir -v /lib/init/rw/resolvconf ; } \
  34.             && { [ -d /lib/init/rw/resolvconf/interface ] || mkdir -v /lib/init/rw/resolvconf/interface ; } \
  35.             && F="$(echo /dev/shm/resolvconf/*)" \
  36.             && [ "$F" ] \
  37.             && [ "$F" != '/dev/shm/resolvconf/*' ] \
  38.             && cp -a /dev/shm/resolvconf/* /lib/init/rw/resolvconf
  39.         then
  40.             report_info "Migrating run-time database from /dev/shm/resolvconf to /lib/init/rw/resolvconf"
  41.             ln -nsf /lib/init/rw/resolvconf /etc/resolvconf/run
  42.         fi
  43.     fi
  44.     # Delete it if it isn't a directory or a link to one
  45.     if [ -e /etc/resolvconf/run ] && [ ! -d /etc/resolvconf/run ] ; then
  46.         report_err "Deleting /etc/resolvconf/run which isn't a directory"
  47.         rm -f /etc/resolvconf/run
  48.     fi
  49.     # Now /etc/resolvconf/run is either
  50.     # * nonexistent, or
  51.     # * a dangling but canonicalizable symlink, or
  52.     # * a symlink to a directory, or
  53.     # * a directory
  54.     if [ -d /etc/resolvconf/run ] ; then
  55.         # It's a directory or a symlink to one
  56.         [ -d /etc/resolvconf/run/interface ] || mkdir -v /etc/resolvconf/run/interface
  57.     elif [ -L /etc/resolvconf/run ] ; then
  58.         # It's a dangling but canonicalizable symlink
  59.         mkdir -v "$RUN_CANONICALPATH" "${RUN_CANONICALPATH}/interface"
  60.     else
  61.         # It's nonexistent
  62.         #
  63.         # TODO: In order to ensure that this code is equivalent to the earlier block,
  64.         #       put it into a function
  65.         #
  66.         if \
  67.             [ -d /lib/init/rw ] \
  68.             && [ -w /lib/init/rw ] \
  69.             && [ -r /proc/mounts ] \
  70.             && grep -qs "^tmpfs[[:space:]]\+/lib/init/rw[[:space:]]\+tmpfs[[:space:]]\+\([^[:space:]]\+,\)\?rw" /proc/mounts \
  71.             && { [ -d /lib/init/rw/resolvconf ] || mkdir -v /lib/init/rw/resolvconf ; } \
  72.             && { [ -d /lib/init/rw/resolvconf/interface ] || mkdir -v /lib/init/rw/resolvconf/interface ; }
  73.         then
  74.             ln -s /lib/init/rw/resolvconf /etc/resolvconf/run
  75.         else
  76.             mkdir -v /etc/resolvconf/run /etc/resolvconf/run/interface
  77.         fi
  78.     fi
  79.     ;;
  80.   # *)
  81.     # In other modes we don't need to do anything
  82.     # because we didn't take any action in the prerm
  83.     # ;;
  84. esac
  85.  
  86. # We use dh_installinit with --no-start
  87. # Automatically added by dh_installinit
  88. if [ -x "/etc/init.d/resolvconf" ]; then
  89.     update-rc.d resolvconf start 38 S . stop 89 0 6 . >/dev/null || exit $?
  90. fi
  91. # End automatically added section
  92.  
  93.  
  94. ### Link tail to original if appropriate ###
  95. TIME_TO_CHANGE_TAIL_LINK=no
  96. case "$1" in
  97.   configure|reconfigure)
  98.     TIME_TO_CHANGE_TAIL_LINK=yes
  99.     ;;
  100. # *)
  101.     # In other modes we don't need to do anything
  102.     # because we didn't take any action in the prerm
  103. esac
  104.  
  105. if [ "$TIME_TO_CHANGE_TAIL_LINK" = yes ] ; then
  106.     if [ ! -e /etc/resolvconf/resolv.conf.d/tail ] ; then
  107.         db_get resolvconf/link-tail-to-original
  108.         if [ "$RET" = "true" ] ; then
  109.             ln -nsf original /etc/resolvconf/resolv.conf.d/tail
  110.         else
  111.             : > /etc/resolvconf/resolv.conf.d/tail
  112.         fi
  113.     fi
  114. fi
  115.  
  116. ### Linkify /etc/resolv.conf if appropriate ###
  117. TIME_TO_CHANGE_LINKIFICATION=no
  118. case "$1" in
  119.   configure|reconfigure)
  120.     TIME_TO_CHANGE_LINKIFICATION=yes
  121.     ;;
  122. # *)
  123.     # In other modes we don't need to do anything
  124.     # because we didn't take any action in the prerm
  125. esac
  126.  
  127. if [ "$TIME_TO_CHANGE_LINKIFICATION" = yes ] ; then
  128.     db_get resolvconf/linkify-resolvconf
  129.     if [ "$RET" = "true" ] ; then
  130.         # Back up
  131.         if \
  132.             [ -f /etc/resolv.conf ] \
  133.             && { \
  134.                 [ ! -L /etc/resolv.conf ] \
  135.                 || [ ! "$(readlink /etc/resolv.conf)" = "/etc/resolvconf/run/resolv.conf" ] ; \
  136.             }
  137.         then
  138.             if [ ! -e /etc/resolvconf/resolv.conf.d/original ] ; then
  139.                 cp -a /etc/resolv.conf /etc/resolvconf/resolv.conf.d/original
  140.             else
  141.                 cp -a /etc/resolv.conf /etc/resolv.conf.dpkg-old
  142.             fi
  143.             # Before creating the link, make sure that the original file is
  144.             # at the target of the link.  /sbin/resolvconf will overwrite
  145.             # this when it runs, of course.
  146.             if [ ! -e /etc/resolvconf/run/resolv.conf ] ; then
  147.                 cp -a /etc/resolv.conf /etc/resolvconf/run/resolv.conf
  148.             fi
  149.         fi
  150.  
  151.         # Create the link
  152.         ln -nsf /etc/resolvconf/run/resolv.conf /etc/resolv.conf
  153.     fi
  154. fi
  155.                                 
  156. db_stop
  157.  
  158. ### Enable updates ###
  159. if [ -x "/etc/init.d/resolvconf" ] ; then
  160.     if which invoke-rc.d >/dev/null 2>&1 ; then
  161.         invoke-rc.d resolvconf enable-updates || :
  162.     else
  163.         /etc/init.d/resolvconf enable-updates
  164.     fi
  165. fi
  166.